package org.apache.jsp.ForumHtml;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import com.sun.xml.internal.txw2.Document;
import java.rmi.Naming;
import server.ForumHandlerInt;
import java.sql.*;

public final class editPost_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.List<java.lang.String> _jspx_dependants;

  static {
    _jspx_dependants = new java.util.ArrayList<java.lang.String>(1);
    _jspx_dependants.add("/ForumHtml/scripts.jsp");
  }

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.List<java.lang.String> getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
  }

  public void _jspDestroy() {
  }

  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=utf-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n");
      out.write("<head>\r\n");
      out.write("\r\n");
      out.write("<link href=\"SpryAssets/SpryMenuBarVertical.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
      out.write("<link href=\"screenStyle.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("\tfunction logoutFunc() {\r\n");
      out.write("\r\n");
      out.write("\t\tvar xmlhttp;\r\n");
      out.write("\r\n");
      out.write("\t\tif (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari\r\n");
      out.write("\t\t\txmlhttp = new XMLHttpRequest();\r\n");
      out.write("\t\t} else {// code for IE6, IE5\r\n");
      out.write("\t\t\txmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");\r\n");
      out.write("\t\t}\r\n");
      out.write("\r\n");
      out.write("\t\txmlhttp.open(\"GET\", \"logout.jsp\", false);\r\n");
      out.write("\t\t//http.open(\"POST\", \"userValidation.jsp\", true);\r\n");
      out.write("\r\n");
      out.write("\t\txmlhttp.send();\r\n");
      out.write("\t\treturn xmlhttp.responseText;\r\n");
      out.write("\t}\r\n");
      out.write("</script>");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("function loadXMLDoc()\r\n");
      out.write("{\r\n");
      out.write("\t\r\n");
      out.write("var xmlhttp;\r\n");
      out.write("var params;\r\n");
      out.write("\r\n");
      out.write("params = \"postId=");
      out.print(request.getParameter("postId"));
      out.write("\"+\"&postTitle=\"+document.editPost.postTitle.value+\"&postContent=\"+document.editPost.postContent.value;\r\n");
      out.write("\r\n");
      out.write("if (window.XMLHttpRequest)\r\n");
      out.write("  {// code for IE7+, Firefox, Chrome, Opera, Safari\r\n");
      out.write("  xmlhttp=new XMLHttpRequest();\r\n");
      out.write("  }\r\n");
      out.write("else\r\n");
      out.write("  {// code for IE6, IE5\r\n");
      out.write("  xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\r\n");
      out.write("  }\r\n");
      out.write("\r\n");
      out.write("  \r\n");
      out.write("xmlhttp.open(\"POST\",\"editPostVa.jsp\",false);\r\n");
      out.write("//http.open(\"POST\", \"userValidation.jsp\", true);\r\n");
      out.write("\r\n");
      out.write("//Send the proper header information along with the request\r\n");
      out.write("xmlhttp.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\r\n");
      out.write("xmlhttp.setRequestHeader(\"Content-length\", params.length);\r\n");
      out.write("xmlhttp.setRequestHeader(\"Connection\", \"close\");\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("xmlhttp.send(params);\r\n");
      out.write("return xmlhttp.responseText;\r\n");
      out.write("}\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

	String postTitle = request.getParameter("postTitle");
	String postContent = request.getParameter("postContent");
	int topicId = Integer.parseInt(request.getParameter("topicId"));
	String topicName = request.getParameter("topicName");

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<!-- script for validating forms fields are all filled -->\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("function validate_form( )\r\n");
      out.write("{\r\n");
      out.write("    valid = true;\r\n");
      out.write("\r\n");
      out.write("    if ( document.editPost.postTitle.value == \"\" )\r\n");
      out.write("    {\r\n");
      out.write("        alert ( \"Please fill in the 'post title' box.\" );\r\n");
      out.write("        valid = false;\r\n");
      out.write("        return valid;\r\n");
      out.write("    }\r\n");
      out.write("    if ( document.editPost.postContent.value == \"\" )\r\n");
      out.write("    {\r\n");
      out.write("        alert ( \"Please fill in the 'post content' box.\" );\r\n");
      out.write("        valid = false;\r\n");
      out.write("        return valid;\r\n");
      out.write("    }\r\n");
      out.write("    \r\n");
      out.write("    loadXMLDoc();\r\n");
      out.write("    return valid;\r\n");
      out.write("}\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n");
      out.write("<link href=\"screenStyle.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
      out.write("<title>Edit Post</title>\r\n");
      out.write("</head>\r\n");
      out.write("\r\n");
      out.write("<body>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<div class=\"pageTitle\">\r\n");
      out.write("\t\t<h1>EDIT POST IN TOPIC:");
      out.print(topicName);
      out.write("</h1>\r\n");
      out.write("\t\t<hr />\r\n");
      out.write("\t</div>\r\n");
      out.write("\r\n");
      out.write("<ul id=\"MenuBar1\" class=\"MenuBarVertical\">\r\n");
      out.write("      <li><a href=\"friends.jsp\">manage friends</a></li>\r\n");
      out.write("      <li><a href=\"mainScreen.jsp\"> main screen</a>  </li>\r\n");
      out.write("      <li><a href=\"topics.jsp?forumId=");
      out.print((Integer)session.getAttribute("forumId"));
      out.write("&forumName=");
      out.print((String)session.getAttribute("forumName"));
      out.write("\"> forum: ");
      out.print((String)session.getAttribute("forumName"));
      out.write("</a>  </li>\r\n");
      out.write("  \t  <li><a href=\"posts.jsp?topicId=");
      out.print(topicId);
      out.write("&topicName=");
      out.print(topicName);
      out.write("\"> topic: ");
      out.print(topicName);
      out.write("</a>  </li>\r\n");
      out.write("        <li><a href=\"index.jsp\"  target=\"_top\" onClick= \"logoutFunc();\">logout</a>  </li>\r\n");
      out.write("</ul>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<form name =\"editPost\" method=post action=\"posts.jsp\" onsubmit=\"return validate_form ( );\">\r\n");
      out.write("  <table width=\"283\" border=\"0\">\r\n");
      out.write("      <tr>\r\n");
      out.write("        <th width=\"120\" scope=\"row\">Post title</th>\r\n");
      out.write("        <td width=\"153\"><input name=\"postTitle\" type=\"text\" value=");
      out.print(request.getParameter("postTitle"));
      out.write(" /></td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <th width=\"120\" scope=\"row\">Post content</th>\r\n");
      out.write("        <td width=\"153\"><textarea rows=\"3\" cols=\"15\" name=\"postContent\">");
      out.print(request.getParameter("postContent"));
      out.write("</textarea></td>\r\n");
      out.write("      </tr>\r\n");
      out.write("    </table>\r\n");
      out.write("    <input name=\"editPost\" type=\"submit\" value=\"save post\" />\r\n");
      out.write(" \r\n");
      out.write("\t<input name=\"topicId\" type=\"hidden\" value=\"");
      out.print(request.getParameter("topicId"));
      out.write("\" />\r\n");
      out.write("\t<input name=\"topicName\" type=\"hidden\" value=\"");
      out.print(request.getParameter("topicName"));
      out.write("\" />\r\n");
      out.write("\r\n");
      out.write("</form>\r\n");
      out.write("\r\n");
      out.write("</body>\r\n");
      out.write("</html>");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
